    import request from '@/utils/request.js'

    export const noticeApi={
        list(noticeQuery){
            return request.get('/notice/list',{params:noticeQuery})
        },
		inform(){
			return request.get('/notice/inform')
		},
		deleteById(id) {
			return request.delete( `/notice/deleteById/${id}`)   //反引号，直接写参数。否则需要字符串拼接
		},
		deleteAll(ids) {
			return request.delete( `/notice/deleteAll/${ids}`)
		},
		add(notice) {
			//notice以JSON形式传递到后台
			return request.post('/notice/add', notice)
		},
		selectById(id) {
			return request.get(`/notice/selectById/${id}`)
		},
		update(notice) {
			return request.put('/notice/update', notice)
		},
		updateStatus(id,status){
			return request.put(`/notice/updateStatus/${id}/${status}`)
		},
		informTotal(){
			return request.get('/notice/informTotal')
		},
		receive(notice) {
			return request.put(`/notice/receive`,notice)
		},
		getNum(state) {
			// 购物车商品总数量
			let totalNum = 0;
			for (let i = 0; i < state.shoppingCart.length; i++) {
				const temp = state.shoppingCart[i];
				totalNum += temp.quantity;
			}
			return totalNum;
		}
    }
    

